import {Injectable, Type} from '@angular/core';
import {DialogComponent} from './dialog/dialog.component';
import {MatDialog} from '@angular/material';
import {Observable} from 'rxjs/Observable';

// import  "rxjs/Operator/of"

@Injectable()
export class DialogService {

  constructor(public dialog: MatDialog) {

  }

  showConfirmationDialog(title: string, message: string): Observable<DialogResult> {
    return this.dialog
      .open(DialogComponent, {data: {title, message}}).afterClosed();
  }

  showDialog(title: string, message: string, dialogContainerType: Type<any>,): Observable<DialogResult> {
    return this.dialog
      .open(dialogContainerType, {data: {title, message}}).afterClosed();
  }

}

export enum DialogResult {
  Ok,
  no,
  cancel
}
